/***
 * ASM Guide
 * Copyright (c) 2007 Eric Bruneton, 2011 Google
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

package cn.zwy.day3;

/**
 * ASM Guide example class.
 * 
 * @author Eric Bruneton
 */
public class Bean {
  private int f;

  public int getF() {
    return f;
  }

  public void setF(int f) {
    this.f = f;
  }

  public void checkAndSetF(int f) {
    if (f >= 0) {
      this.f = f;
    } else {
      throw new IllegalArgumentException();
    }
  }
}

/*$ javap -verbose Bean.class
Classfile /F:/workspace/CodeExample/ByteCodeOperation/target/classes/cn/zwy/day3/Bean.class
  Last modified 2017-11-14; size 640 bytes
  MD5 checksum 51ebbefbf04377a394e3f7e224a133aa
  Compiled from "Bean.java"
public class cn.zwy.day3.Bean
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Class              #2             // cn/zwy/day3/Bean
   #2 = Utf8               cn/zwy/day3/Bean
   #3 = Class              #4             // java/lang/Object
   #4 = Utf8               java/lang/Object
   #5 = Utf8               f
   #6 = Utf8               I
   #7 = Utf8               <init>
   #8 = Utf8               ()V
   #9 = Utf8               Code
  #10 = Methodref          #3.#11         // java/lang/Object."<init>":()V
  #11 = NameAndType        #7:#8          // "<init>":()V
  #12 = Utf8               LineNumberTable
  #13 = Utf8               LocalVariableTable
  #14 = Utf8               this
  #15 = Utf8               Lcn/zwy/day3/Bean;
  #16 = Utf8               getF
  #17 = Utf8               ()I
  #18 = Fieldref           #1.#19         // cn/zwy/day3/Bean.f:I
  #19 = NameAndType        #5:#6          // f:I
  #20 = Utf8               setF
  #21 = Utf8               (I)V
  #22 = Utf8               checkAndSetF
  #23 = Class              #24            // java/lang/IllegalArgumentException
  #24 = Utf8               java/lang/IllegalArgumentException
  #25 = Methodref          #23.#11        // java/lang/IllegalArgumentException."<init>":()V
  #26 = Utf8               StackMapTable
  #27 = Utf8               SourceFile
  #28 = Utf8               Bean.java
{
  public cn.zwy.day3.Bean();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #10                 // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 38: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcn/zwy/day3/Bean;

  public int getF();
    descriptor: ()I
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: getfield      #18                 // Field f:I
         4: ireturn
      LineNumberTable:
        line 42: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lcn/zwy/day3/Bean;

  public void setF(int);
    descriptor: (I)V
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: iload_1
         2: putfield      #18                 // Field f:I
         5: return
      LineNumberTable:
        line 46: 0
        line 47: 5
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcn/zwy/day3/Bean;
            0       6     1     f   I

  public void checkAndSetF(int);
    descriptor: (I)V
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: iload_1
         1: iflt          12
         4: aload_0
         5: iload_1
         6: putfield      #18                 // Field f:I
         9: goto          20
        12: new           #23                 // class java/lang/IllegalArgumentException
        15: dup
        16: invokespecial #25                 // Method java/lang/IllegalArgumentException."<init>":()V
        19: athrow
        20: return
      LineNumberTable:
        line 50: 0
        line 51: 4
        line 52: 9
        line 53: 12
        line 55: 20
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      21     0  this   Lcn/zwy/day3/Bean;
            0      21     1     f   I
      StackMapTable: number_of_entries = 2
        frame_type = 12  same 
        frame_type = 7  same 
}
SourceFile: "Bean.java"
*/